package com.gitee.wsl.ext.number

import kotlin.math.roundToInt

/** Divides [this] into [that] rounding to the floor */
 infix fun Int.divFloor(that: Int): Int = this / that
/** Divides [this] into [that] rounding to the ceil */
 infix fun Int.divCeil(that: Int): Int = if (this % that != 0) (this / that) + 1 else (this / that)
/** Divides [this] into [that] rounding to the round */
 infix fun Int.divRound(that: Int): Int = (this.toDouble() / that.toDouble()).roundToInt()

 infix fun Long.divCeil(other: Long): Long {
    val res = this / other
    if (this % other != 0L) return res + 1
    return res
}

@Suppress("NOTHING_TO_INLINE")
inline fun UInt.divCeil(other: UInt) =
    (floorDiv(other)) + (if (rem(other) != 0u) 1u else 0u)

//@Suppress("NOTHING_TO_INLINE")
//inline fun Int.ceilDiv(other: Int) =
//    (floorDiv(other)) + (if (rem(other) != 0) 1 else 0)